<template>
	<view class="collection">
		<uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
			activeColor="#4cd964"></uni-segmented-control>
		<view class="content">
			<view v-show="current === 0">
				<couua :data="data"></couua>
			</view>
			<view v-show="current === 1">
				<education :line="line"></education>
			</view>
		</view>

	</view>

	<BottomText></BottomText>
</template>

<script setup>
	import education from "@/components/Education-headline/Education-headline.vue"
	import BottomText from "@/components/BottomText/BottomText.vue"
	import couua from "@/components/couua/couua.vue"
	import http from "@/utils/http.js"
	import {
		ref,
		onMounted
	} from 'vue';
	const line = ref([])
	const data = ref([])
	const items = ['热门课程', '教育头条'];
	let current = ref(0);
	const onClickItem = function(e) {

		if (current.value !== e.currentIndex) {
			current.value = e.currentIndex
		}
	};
	const scData = function() {
		http({
			url: "/user/collect/courseList",
			params: {
				wechatName: "心死绿稻田"
			},
		}).then((res) => {
			console.log(res);
			for (let s of res.data) {
				let {
					coursename,
					courseprice,
					url
				} = s.courseList[0]
				let courseId=s.courseId
				data.value.push({
					coursename,
					courseprice,
					url,
					courseId
				})
			}
			console.log('gvs',data.value);
		})
	};
	const ttData = function(){
		http({
			url:'/user/collect/articleList',
			params:{
				wechatName: "小瓶盖"
			},
		}).then((res)=>{
			console.log(2,res);
			if(res.code===0){
				line.value=res.data
				console.log("aa" ,line.value);
			}
		})
		console.log(line.value,111);
	}
	onMounted(()=>{
		scData();
		ttData()
	})
</script>

<style lang="less" scoped>
	.chosen {
		border-bottom: 3px solid;
		color: #000;
	}

	.hode {
		display: flex;
		height: 80rpx;

		view {
			flex: 1;
			color: #CCCCCC;
			text-align: center;
			font-size: 32rpx;
			line-height: 100%;

			text {
				display: inline-block;
				line-height: 80rpx;
				font-weight: 700;

			}
		}
	}
</style>
